package com.zbkj.front.controller.mszs;

import com.zbkj.common.model.mszs.MszsHotel;
import com.zbkj.common.page.CommonPage;
import com.zbkj.common.request.PageParamRequest;
import com.zbkj.common.request.mszs.MszsHotelRequest;
import com.zbkj.common.request.mszs.MszsHotelSelectRequest;
import com.zbkj.common.response.CommonResult;
import com.zbkj.common.response.mszs.MszsHotelResponse;
import com.zbkj.service.service.mszs.MszsHotelService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @description 民宿助手酒店基本信息-controller层
 * @author JIANTAO
 * @date 2023-11-16
 */
@Slf4j
@RestController("MszsHotelFrontController")
@RequestMapping("api/front/mszs/hotel")
@Api(tags = "民宿助手-酒店基本信息")
public class MszsHotelFrontController {

    @Resource
    private MszsHotelService hotelService;

    @ApiOperation(value="新增-酒店信息")
    @RequestMapping(value = "/insert",method = RequestMethod.POST)
    public CommonResult<Boolean> insert(@RequestBody @Validated MszsHotelRequest request){
        return CommonResult.success(hotelService.insert(request));
    }

    @ApiOperation(value="修改-酒店信息")
    @RequestMapping(value = "/update",method = RequestMethod.POST)
    public CommonResult<Boolean> update(@RequestBody @Validated MszsHotelRequest request){
        return CommonResult.success(hotelService.update(request));
    }

    @ApiOperation(value="刪除-根据id标识删除")
    @RequestMapping(value = "/delete", method = RequestMethod.GET)
    @ApiImplicitParam(name = "id", value = "主键id标识",required = true)
    public CommonResult<Boolean> del(@RequestParam("id")String id){
        return CommonResult.success(hotelService.delete(id));
    }

    @ApiOperation(value="查询-根据主键id查询")
    @RequestMapping(value = "/load", method = RequestMethod.GET)
    @ApiImplicitParam(name = "id", value = "主键id标识",required = true)
    public CommonResult<MszsHotelResponse> load(@RequestParam("id") String id) {
        return CommonResult.success(hotelService.load(id));
    }
    
    @ApiOperation(value="查询-分页查询")
    @RequestMapping(value = "/pageList", method = RequestMethod.GET)
    public CommonResult<CommonPage<MszsHotel>> pageList(
            @Validated MszsHotelSelectRequest request,
            @Validated PageParamRequest pageParamRequest) {
        CommonPage<MszsHotel> mszsOrderPage = CommonPage.restPage(hotelService.pageList(request,pageParamRequest));
        return CommonResult.success(mszsOrderPage);
    }
}
